package acme.ws;

import java.io.IOException;
import java.io.InputStream;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ContentSizeServlet extends JSONServlet{

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String contentType = req.getContentType();
		InputStream is = req.getInputStream();
		long length = Util.getStreamLength(is);
		Response response = new Response();
		response.contentType = contentType;
		response.length = length;
		
		returnJSON(response, resp);
	}
	
	private static class Response{
		String contentType = null;
		long length = -1;
	}

}
